package com.tms.operation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.tms.operation.domain.TmsOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.operation.domain.TmsDraw;
import com.tms.operation.service.ITmsDrawService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 到站Controller
 *
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/draw")
public class TmsDrawController extends BaseController
{
    @Autowired
    private ITmsDrawService tmsDrawService;

    /**
     * 查询到站列表
     */
    @RequiresPermissions("draw:draw:list")
    @GetMapping("/list")
    public TableDataInfo list(TmsDraw tmsDraw)
    {
        startPage();
        List<TmsDraw> list = tmsDrawService.selectTmsDrawList(tmsDraw);
        return getDataTable(list);
    }

    /**
     * 导出到站列表
     */
    @RequiresPermissions("draw:draw:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, TmsDraw tmsDraw)
    {
        List<TmsDraw> list = tmsDrawService.selectTmsDrawList(tmsDraw);
        ExcelUtil<TmsDraw> util = new ExcelUtil<TmsDraw>(TmsDraw.class);
        util.exportExcel(response, list, "到站数据");
    }

    /**
     * 获取到站详细信息
     */
    @RequiresPermissions("draw:draw:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tmsDrawService.selectTmsDrawById(id));
    }

    /**
     * 新增到站
     */
    @RequiresPermissions("draw:draw:add")
    @PostMapping
    public AjaxResult add(@RequestBody TmsDraw tmsDraw)
    {
        return toAjax(tmsDrawService.insertTmsDraw(tmsDraw));
    }

    /**
     * 修改到站
     */
    @RequiresPermissions("draw:draw:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody TmsDraw tmsDraw)
    {
        return toAjax(tmsDrawService.updateTmsDraw(tmsDraw));
    }

    /**
     * 删除到站
     */
    @RequiresPermissions("draw:draw:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tmsDrawService.deleteTmsDrawByIds(ids));
    }
    @RequiresPermissions("draw:draw:edit")
    @PutMapping("status")
    public AjaxResult editStatus(@RequestBody TmsDraw tmsDraw){
    	return success(tmsDrawService.updateTmsDraw(tmsDraw));
    }


    //统计
    @GetMapping("/countDriver")
    public TableDataInfo countdraw() {
        List<TmsDraw> list = tmsDrawService.countdraw();
        return getDataTable(list);
    }

    //获取异常运单
    @GetMapping("/exceptDraw")
    public TableDataInfo exceptDraw()
    {
        List<TmsDraw> list = tmsDrawService.exceptDraw();
        return getDataTable(list);
    }
}
